//
//  saveSandBox.h
//  FCPackage
//
//  Created by WJC on 2018/11/2.
//  Copyright © 2018 wjc. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface saveSandBox : NSObject
//当前app版本号
+(NSString*)getCurrentVersion;
/**
 本方法是得到 UUID 后存入系统中的 keychain 的方法
 不用添加 plist 文件
 程序删除后重装,仍可以得到相同的唯一标示
 但是当系统升级或者刷机后,系统中的钥匙串会被清空,此时本方法失效
 */
+(NSString *)getDeviceIDInKeychain;
//获取当前app的环境
+(NSString*)getCurrentEnvironment;
+(void)removeFilePath:(NSString*)path;
/**
 HTML缓存,
 */
+(void)saveJSLocalWithData:(NSURL *)jsurl andurlName:(NSString*)urlName andVersion:(NSString*)version;
+(NSData*)getJSLocalWithUrlName:(NSString *)urlName andVersion:(NSString *)version;
+(void)createTableWithTableViewName:(Class)saveClass;
/**
 文件式缓存,用于个人数据(每个模型只能存取一次,列表不能使用)
 */
+(void)saveLocalWithClass:(Class)saveClass andObject:(id)object;
+(void)removeLocalWithClass:(Class)saveClass;
+(void)saveLocalDataWithName:(NSString*)name andObject:(NSData*)object;
/**
获取 文件式缓存
 */
+(id)getLocalWithClass:(Class)saveClass;
+(NSData*)getLocalDataWithName:(NSString*)name;
/**
 nsuserdefault保存
 */
+(void)saveSandBoxWithDic:(NSDictionary*)dic;
/**
 nsuserdefault获取
 */
+(id)getSandBoxWithKey:(NSString*)key;


/**
 
  数据库储存缓存/更新

 @param BaseName 数据库名称(枚举)
 @param object 缓存文件
 @param type 保存文件的查找唯一值,当值相同时缓存🏆替换(建议Id)
 */
+(void)saveDataBaseClass:(Class)saveClass andObject:(id)object orType:(NSString *)type andOther:(NSString *)other;

/**
 删除缓存

 @param type 删除条件
 @param saveClass 删除l表
 */
+(void)DELETEDataWithType:(NSString*)type andOther:(NSString *)other andClass:(Class)saveClass;

/**
 获取缓存

 @param saveClass 获取缓存表
 @param limitType 限制条件
 @return 返回model
 */
+(id)getDataBaseWithClass:(Class)saveClass andLimitType:(NSString *)limitType;




/**
 获取cookie缓存
 */
+(NSArray <NSHTTPCookie*>*)getCookie;

/**
 全局设置cookie
 */
+(void)setCookie;

/**
 删除cookie
 */
+(void)deleteCookies;

/**
 保存cookie

 @param storage 请求后的storage
 */
+(void)saveCookieWithCookie:(NSHTTPCookieStorage*)storage;
/**
 保存cookie
 
 @param storage 请求后的storage
 */
+(void)addCookieWithCookie:(NSHTTPCookieStorage*)storage;

/// 直接添加一个cookie
/// @param cookie cookie
+(void)addoneCookie:(NSHTTPCookie *)cookie;
/**
 删除本地数据

 @param deleteCookie 是否一起删除cookie
 */
+(void)deleteAllObjectWithCookie:(BOOL)deleteCookie;

+ (NSDate *)currentTime;
//工程api地址获取
+(NSString*)returnAPIWithName:(NSString*)str;
-(void)deleteDefaultWithKey:(NSString*)key;
-(void)removeLibraryCache;
-(void)removeDocumentCache;
///. 清除缓存
+ (void)clearSandBoxFile;
///获取缓存大小(MB)
+( float )getCacheSize;

#pragma mark -- 新sqlite数据库H5储存,后续的清空缓存不会删除该库
+(void)createH5TableWithTableViewName:(Class)saveClass;
+(void)saveH5DataBaseClass:(Class)saveClass andObject:(id)object orType:(NSString *)type andOther:(NSString *)other;
+(void)DELETEH5DataWithType:(NSString*)type andOther:(NSString *)other andClass:(__unsafe_unretained Class)saveClass;
+(void)insertH5DataWithDic:(NSDictionary *)content andClass:(Class)saveClass orType:(NSString*)type andOther:(NSString *)other;
+(void)updateH5DataWithDic:(NSDictionary *)content andClass:(Class)saveClass orType:(NSString*)type andOther:(NSString *)other;
+(id)getH5DataBaseWithClass:(Class)saveClass andLimitType:(NSString *)limitType;


#pragma mark -- 新sqlite数据库储存
///建表
+(void)createNewDataBaseWithTableViewClass:(Class)saveClass;
///删
+(void)DELETENewDataWithDic:(id)content andClass:(Class)saveClass;
///增
+(void)insertNewDataBaseWithDic:(id)content andClass:(Class)saveClass orType:(NSString*)type andOther:(NSString *)other;
///改
+(void)updateNewDataBaseWithDic:(id)content andClass:(Class)saveClass orType:(NSString *)type andOther:(NSString *)other;
///查
+(NSArray*)getNewDataBaseWithClass:(Class)saveClass andLimitType:(NSString *)limitType andGetSub:(BOOL)getSub;
@end
